function isConvex() : boolean; // P - array of pt; n - pt count

var
	f, s, t, i : longint;
	ok, cur : boolean;

	function v(x1, y1, x2, y2 : int64) : int64;
	begin
		result := x1 * y2 - x2 * y1;
	end;

begin       
	result := true;
	f := 1;
	s := 2;
	t := 3;
	ok := true;
	cur := v(p[s].x - p[f].x, p[s].y - p[f].y, p[t].x - p[s].x, p[t].y - p[s].y) >= 0;
	for i := 2 to n do begin
		f := i;
		s := i mod n + 1;
		t := (i + 1) mod n + 1;
		if (v(p[s].x - p[f].x, p[s].y - p[f].y, p[t].x - p[s].x, p[t].y - p[s].y) >= 0) <> cur then begin
			ok := false;
			break;
		end;
	end;
	if ok then exit;
	f := 1;
	s := 2;
	t := 3;
	ok := true;
	cur := v(p[s].x - p[f].x, p[s].y - p[f].y, p[t].x - p[s].x, p[t].y - p[s].y) <= 0;
	for i := 2 to n do begin
		f := i;
		s := i mod n + 1;
		t := (i + 1) mod n + 1;
		if (v(p[s].x - p[f].x, p[s].y - p[f].y, p[t].x - p[s].x, p[t].y - p[s].y) <= 0) <> cur then begin
			ok := false;
			break;
		end;
	end;
	result := ok;
end;